﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using Enities;

namespace QLThuVien_Nhom21
{
    public partial class BaoCaoViPham : Form
    {
        public BaoCaoViPham()
        {
            InitializeComponent();
        }

        LuuTruBCVP baocao = new LuuTruBCVP();
       


        private void btnxem_Click(object sender, EventArgs e)
        {
            dtgwBCVP.DataSource = baocao.DanhSach();

        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtMaDG.Text.Length !=7)
            {
                MessageBox.Show("Ma doc gia phai 7 ky tu", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else
            {

                BaoCaoVP bc = new BaoCaoVP();
                bc.MaDocGia = int.Parse(txtMaDG.Text);
                bc.TenDocGia = txtHoTen.Text;
                bc.NgayMuon = dtNgayMuon.Value;
                bc.NgayThucTra = dtNgayThucTra.Value;
                bc.LyDoViPham = cbblydovipham.Text;
                bc.HinhThucXuLy = cbbhinhthucxuly.Text;
                baocao.Them(bc);
            }
            dtgwBCVP.DataSource = baocao.DanhSach();

        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (txtMaDG.Text == "")
            {
                MessageBox.Show("khong duoc bo trong", "loi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {

                BaoCaoVP bc = new BaoCaoVP();
                bc.MaDocGia = int.Parse(txtMaDG.Text);
                bc.TenDocGia = txtHoTen.Text;
                bc.NgayMuon = dtNgayMuon.Value;
                bc.NgayThucTra = dtNgayThucTra.Value;
                bc.LyDoViPham = cbblydovipham.Text;
                bc.HinhThucXuLy = cbbhinhthucxuly.Text;
                baocao.Sua(bc);
            }
            dtgwBCVP.DataSource = baocao.DanhSach();

        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            
        }

        private void bttTKVP_Click(object sender, EventArgs e)
        {
            if (txtMaDGTK.Text == "")
            {
                MessageBox.Show("Nhap vao tu khoa tim kiem", "loi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                dtgwTKBC.DataSource = baocao.TimKiem(int.Parse(txtMaDGTK.Text));

            }
        }
      
    }
}
